Skip to content

fix(chat): user-bubble word-wrap — give .chat-message__layout width:100%#362

Merged
blove merged 2 commits into
mainfrom
claude/chat-message-bubble-width
May 16, 2026
Merged

fix(chat): user-bubble word-wrap — give .chat-message__layout width:100%#362
blove merged 2 commits into
mainfrom
claude/chat-message-bubble-width

Conversation

@blove
Copy link
Copy Markdown
Contributor

@blove blove commented May 16, 2026

Summary

Short user messages like "Show me the dashboard" wrap mid-phrase ("Show me the" / "dashboard"). Fixed three times before — see PRs #313, #325, c0b9e88 — each tweak shifted which element holds the max-width: 80% cap, but none addressed why the cap can't compute correctly.

Root cause (verified live in chrome)

  • User-role host is display: flex; justify-content: flex-end with no width on .chat-message__layout
  • .chat-message__main has max-width: 80% which resolves against .chat-message__layout (its containing block)
  • .chat-message__layout itself shrinks to __main's content (single-child flex container, no defined width)
  • Circular dependency: bubble fit-content depends on __main's width, __main's 80% depends on layout, layout depends on bubble

Browser breaks the cycle by capping the bubble at its wrap-point intrinsic width instead of max-content. Direct measurement:

bubble forced max-content = 199.75 px  (one-line natural)
bubble forced min-content = 101.42 px  (longest word "dashboard")
bubble fit-content        = 166.20 px  ← the bug — neither extreme
layout actual width       = 207.75 px  (NOT 720px host)

That ~166px (minus 24px padding) is too narrow for "Show me the dashboard" → mid-phrase wrap.

Fix

  • .chat-message__layout { width: 100% } — gives __main's max-width: 80% a concrete, full-row containing block
  • Host for user role: display: block (was flex); right-alignment moves to layout via justify-content: flex-end

The 80% cap stays exactly where it was; we just make it resolve against a real number.

Test plan

  • Chrome MCP after fix: bubbleW = 199.75 px, mainW = 199.75 px, layoutW = 720 px, screenshot confirms "Show me the dashboard" renders single-line and right-aligned
  • CI: Library — lint / test / build

Files

  • libs/chat/src/lib/primitives/chat-message/chat-message.component.ts.chat-message__layout { width: 100% } + comment explaining the prior-PR history
  • libs/chat/src/lib/styles/chat-message.styles.ts — host user-role: display:block; layout user-role: justify-content:flex-end

🤖 Generated with Claude Code

Short user messages like "Show me the dashboard" wrap mid-phrase
("Show me the" / "dashboard"). Fixed three times before in #313, #325,
and c0b9e88, each by tweaking which element holds the 80% cap — none
addressed the architecture.

Root cause: user-role host is `display:flex; justify-content:flex-end`
with no width on .chat-message__layout. __main has max-width:80%, which
resolves against layout (its containing block). Layout in turn shrinks
to __main's content (flex item with auto basis). The browser breaks the
circular dependency by capping the bubble at its fit-content intrinsic
(~166px = the wrap-point width) instead of max-content (~200px = full
text on one line). Verified live: forced max-content = 199.75px,
fit-content = 166.20px, with old layoutW = 207.75px — the bug is exact.

Fix: layout gets width:100% so __main's 80% has a concrete (and full-
row) containing block. Host switches from flex to block; right-alignment
moves down to layout (`justify-content: flex-end` on the layout flex
container).

Verified via chrome MCP after fix: bubbleW = 199.75px (full max-content),
mainW = 199.75px, layoutW = 720px (full row), bubble renders single-line
right-aligned.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cacheplane Ready Ready Preview, Comment May 16, 2026 4:14pm

Request Review

@blove blove merged commit 49771d7 into main May 16, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant